/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.niedziela12.pai.ejb.hotel.facades;

import com.niedziela12.pai.ejb.AbstractFacade;
import com.niedziela12.pai.ejb.entities.Hotel;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Kamil
 */
@Stateless
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class HotelFacade extends AbstractFacade<Hotel> implements HotelFacadeLocal {
    @PersistenceContext(unitName = "com.niedziela12.pai.ejb")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public HotelFacade() {
        super(Hotel.class);
    }

    @Override
    public List<Integer> findAllIds() {
        return em.createQuery("SELECT h.id FROM Hotel h").getResultList();
    }

    @Override
    public List<Integer> findAllHotelsInCity(String city) {
        return em.createQuery("SELECT h.id FROM Hotel h WHERE h.city='"+city+"'").getResultList();
    }
    
}
